﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VSD.OneStopService.BLL;
//using NOAH.Web.Framework.FileDective;
using System.IO;


public partial class Modules_DownloadFile : System.Web.UI.Page
{
    string elementId = string.Empty;
    string profileId = string.Empty;

    protected void Page_Load(object sender, EventArgs e)
    {
        elementId = Request.QueryString["id"] ?? "0";
        profileId = Request.QueryString["pid"] ?? "0";


        ServiceElementRepository repository = new ServiceElementRepository();
        ServiceElement element = repository.Get(int.Parse(elementId));
        ProfileDataRepository profileDataRepository = new ProfileDataRepository();
        ProfileData profileData = profileDataRepository.GetByProfileIdAndElementId(int.Parse(profileId), int.Parse(elementId));

        //if (profileData != null && profileData.AttachmentName != null && profileData.Attachment != null)
        //{
        //    byte[] fileData = profileData.Attachment.ToArray();
        //    FileType fileType = FileDetective.GetFileType(fileData);
        //    Response.AddHeader("Content-type", fileType.Mime);
        //    Response.AddHeader("Content-Disposition", "attachment; filename=" +  profileData.AttachmentName );
        //    Response.BinaryWrite(fileData);
        //    Response.Flush();
        //    Response.End();
        //}
        //else
        //{
        //    Page.Response.Write("Không có file đính kèm");
        //}


    }
}